//package com.chinaoly.baotou.common.utils;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.http.HttpEntity;
//import org.apache.http.StatusLine;
//import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.DefaultHttpClient;
//import org.apache.http.util.EntityUtils;
//import org.apache.shiro.util.CollectionUtils;
//
//import java.util.Map;
//
///**
// * @author dengpu
// * @date 2022/8/30 16:23
// */
//
//@Slf4j
//public class HttpUtil {
//    public static String get(String url, Map<String, String> header) {
//        try {
//            CloseableHttpClient httpClient;
//            if (url.startsWith("https"))
//                httpClient = new SSLClient();
//            else
//                httpClient = new DefaultHttpClient();
//            final HttpGet httpPost = new HttpGet(url);
//            if (!CollectionUtils.isEmpty(header)) {
//                header.forEach(httpPost::addHeader);
//            }
//            CloseableHttpResponse response2;
//
//            response2 = httpClient.execute(httpPost);
//            final StatusLine sl = response2.getStatusLine();
//            final int statusCode = sl.getStatusCode();
//            final HttpEntity responseEntity = response2.getEntity();
//            return EntityUtils.toString(responseEntity);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            log.error("请求失败", ex);
//        }
//        return "";
//    }
//
//    public static String HttpPost(String url, Map<String, String> header, String jsonString) {
//        try {
//            CloseableHttpClient httpClient;
//            if (url.startsWith("https"))
//                httpClient = new SSLClient();
//            else
//                httpClient = new DefaultHttpClient();
//            final HttpPost httpPost = new HttpPost(url);
//            if (!CollectionUtils.isEmpty(header)) {
//                header.forEach(httpPost::addHeader);
//            }
//            if (StringUtils.isNotBlank(jsonString)) {
//                StringEntity stringEntity = new StringEntity(jsonString, "UTF-8");
//                httpPost.setEntity(stringEntity);
//            }
//            CloseableHttpResponse response2 = httpClient.execute(httpPost);
//            final StatusLine sl = response2.getStatusLine();
//            final int statusCode = sl.getStatusCode();
//            log.info("请求返回状态码{}", statusCode);
//            final HttpEntity responseEntity = response2.getEntity();
//            final String jsonStr = EntityUtils.toString(responseEntity);
//            return jsonStr;
//        } catch (Exception ex) {
//            log.error("请求失败", ex);
//        }
//        return "";
//    }
//}